/**
 * Created by ercha on 2016/1/2.
 * 存放一些转换的函数
 */

//将字符串数组转成 JSON string 并返回
//r == false 时，将单斜杠替换成双斜杠，默认替换
function makeJSONStr(array, r){
    if(arguments.length < 2){
        r = true;
    }
    var res = "";
    res += '[';
    for(var i=0; i<array.length; ++i){
        res += "\"" + (array[i]) + "\",";
    }
    res.substr(0, res.length-1);
    res += "]";

    //将单斜杠替换成双斜杠
    if(r){
        var b = /\\/gi;
        res = res.replace(b, "\\\\");
    }
    console.info("res: " + res);
    return res;
}

function str2img(str, img, imgHost){
    if(arguments.length < 3){
        imgHost = host;
    }
    return "<img src =\"" +  str + "\"  alt=\"暂无图片\" width=\"100px\" height=\"100px\">";
}

//将数据库的数值转成字符串
//i: 要转换的数
//array: str 数组
function i2s(i, array){

}